<extend name="Layout/ins_page" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="0">
	{:W('PageHeader/simple',array('name'=>$tag_name))}
	<div class="oprator-panel">
		<a href="{:U('index')}" class="btn">返回</a>
		<div class="split"></div>
		<a id="btn_add" class="btn">新增</a>
		<a id="btn_save" class="btn">保存</a>
		&nbsp;|&nbsp;
		<a id="btn_del" class="btn btn-del">删除</a>
	</div>
	<div class="row">
		<div class="col-sm-4 sub-sidebar ">
			<div class="well">
				<?php echo $menu ?>
			</div>
		</div>
		<div class="layui-input-block ">
			<form id="form_data" name="form_data" method="post" class="layui-form well">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="pid" id="pid" >
				<input type="hidden" name="opmode" id="opmode" value="">
				<select name="tag_list" id="tag_list" class="hidden">
					{:fill_option($tag_list)}
				</select>
				<div class="layui-form-item">
					<label class="layui-form-label" for="name">名称：</label>
					<div class="layui-input-block">
						<input type="text" id="name" name="name" check="required" info="请输入名称" class="layui-input">
					</div>
				</div>
				<if condition="$has_pid">
					<div class="layui-form-item">
						<label class="layui-form-label" for="tag_name">父节点*：</label>
						<div class="layui-input-block">
							<div class="input-group">
								<input name="tag_name" class="layui-input" id="tag_name" type="text" readonly="readonly"/>
								<span class="input-group-btn">
									<button class="btn" id="btn_select_pid" type="button">
										选择
									</button> </span>
							</div>
						</div>
					</div>
				</if>
				<div class="layui-form-item">
					<label class="layui-form-label" for="sort">排序：</label>
					<div class="layui-input-block">
						<input type="text" id="sort" name="sort" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" for="is_del">状态：</label>
					<div class="layui-input-block">
						<select   name="is_del" id="is_del" class="layui-input col-10">
							<option  value="0">启用</option>
							<option value="1">禁用</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" for="remark">备注：</label>
					<div class="layui-input-block">
						<textarea id="remark" name="remark" class="col-xs-12 layui-input"></textarea>
					</div>
				</div>
		</div>
		</form>
	</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		function add() {
			$("#opmode").val("add");
			$("#id").val("");
			send_form("form_data", "", "__SELF__");
		};

		function del() {
			ui_confirm('相应的子目录也会自动删除,真的要删除吗?', function() {
				$("#opmode").val("del");
				send_form("form_data", "", "__SELF__");
			});
		}

		function save() {

			send_form("form_data", "", "__SELF__");

		};

		function showdata(result) {
			for (var s in result.data) {
				set_val(s, result.data[s]);
			}
			$("#opmode").val("edit");
		}

		function select_pid() {
			winopen("{:U('user_tag/winpop','controller='.CONTROLLER_NAME)}", 560, 470);
		}


		$(document).ready(function() {
			$(".sub-sidebar .tree_menu  a").click(function() {
				$(".sub-sidebar .tree_menu  a").each(function() {
					$(this).attr("class", "");
				});
				$(this).attr("class", "active");
				send_ajax("{:U('user_tag/read')}", "id=" + $(this).attr("node"), function(data) {
					showdata(data);
				});
				return false;
			});
		});
	</script>
</block>